package org.wattdepot.cli.command;

import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
 * Tests the chart method with various inputs for correct outputs.
 * 
 * @author Alex Kan and Kelvin Green
 * @version 2.0
 */
public class TestWattDepotChart {

  WattDepotCommand commandInstance;
  String[] commandArray;
  String userInput;

  /**
   * testChart: Checks for 2 correct outputs and errors on 2 inputs. Test (correct) chart power
   * generated SIM_WAIAU_5 2009-11-06 2009-11-10 sampling-interval 30 file
   * kahe-september-energy.html: Data was successfully written to Test (correct) chart power
   * generated SIM_WAIAU_5 2009-11-06 2009-11-10 sampling-interval 30 file kahe-october-energy.html:
   * Data was successfully written to Test (error) chart power generated SIM_WAIAU_11 2009-11-06
   * 2009-11-10 sampling-interval 30 file kahe-september-energy.html: The specified source was not
   * found. Test (error) chart power generated SIM_WAIAU_12 2009-11-06 2009-11-10 sampling-interval
   * 30 file kahe-september-energy.html: The specified source was not found.
   */
  @Test
  public void testChart() {
    WattDepotCommand.connect("http://server.wattdepot.org:8182/wattdepot/");
    commandInstance = new WattDepotChartCommand();
    userInput =
        "chart power generated SIM_WAIAU_5 2009-11-06 2009-11-10 sampling-interval 30 file" + 
        " kahe-september-energy.html";
    commandArray = userInput.split(" ");
    assertTrue("Check for chart power generated for SIM_WAIAU_5", commandInstance.doCommand(
        commandArray).contains("Data was successfully written to"));

    userInput =
        "chart power generated SIM_WAIAU_5 2009-11-06 2009-11-10 sampling-interval 30 file" + 
        " kahe-october-energy.html";
    commandArray = userInput.split(" ");
    assertTrue("Check for SIM_WAIAU_7", commandInstance.doCommand(commandArray).contains(
        "Data was successfully written to"));

    userInput =
        "chart power generated SIM_WAIAU_11 2009-11-06 2009-11-10 sampling-interval 30 file" + 
        " kahe-september-energy.html";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "The specified source was not found."));

    userInput =
        "chart power generated SIM_WAIAU_12 2009-11-06 2009-11-10 sampling-interval 30 file" + 
        " kahe-september-energy.html";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "The specified source was not found."));

  }

}
